package com.fita.wechat.utils;

import org.apache.commons.lang3.CharUtils;
import org.apache.commons.lang3.StringUtils;

import net.sourceforge.pinyin4j.PinyinHelper;

/**
 * @author Guangli Yan
 *
 */
public class PinYinUtils {
	
	public static String getFirstPinYin(String chineseName) {
		
		if (StringUtils.isNotBlank(chineseName)) {
			
			String[] hanyuPinyinStringArray = PinyinHelper.toHanyuPinyinStringArray(CharUtils.toChar(chineseName));
			
			String first = hanyuPinyinStringArray[0].substring(0, 1);
			
			return first;
		}else {
			return "z";
		}
	}

}
